package com.ssy.lingxi.product.common.enums;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 商品导入模板列名
 * @author jw.chen
 * @version 2.0.0
 * @date 2022/3/29
 */
public enum CommodityTemplateEnum {
    Name(1, "商品名称(必填)"),
    Slogan(2, "商品标语"),
    SellingPoint1(3, "商品卖点1"),
    SellingPoint2(4, "商品卖点2"),
    SellingPoint3(5, "商品卖点3"),
    Brand(6, "商品品牌"),
    Unit(7, "计量单位(必填)"),
    SubUnit(8, "计量副单位"),
    MinOrder(9, "最小起订"),
    PriceType(10, "商品定价(必填)"),
    CustomerCategory(11, "品类(必填)"),
    CommodityAttribute1(12, "属性1"),
    CommodityAttributeValue1(13, "属性1的属性值"),
    CommodityAttribute2(14, "属性2"),
    CommodityAttributeValue2(15, "属性2的属性值"),
    CommodityAttribute3(16, "属性3"),
    CommodityAttributeValue3(17, "属性3的属性值"),
    CommodityAttribute4(18, "属性4"),
    CommodityAttributeValue4(19, "属性4的属性值"),
    CommodityAttribute5(20, "属性5"),
    CommodityAttributeValue5(21, "属性5的属性值"),
    ImageType(22, "图片设置方式(必填)"),
    SKUImage(23, "SKU商品图片(必填)"),
    Price(24, "单价(元)"),
    PriceRate(25, "副单位单价换算比率"),
    Goods(26, "物料名称"),
    Image(27, "商品详情图片"),
    Video(28, "商品详情视频"),
    Word(29, "商品详情描述"),
    DeliveryType(30, "配送方式(必填)"),
    CarriageType(31, "运费方式(必填)"),
    Weight(32, "重量"),
    Template(33, "运费模板"),
    SendAddress(34, "发货(自提)地址"),
    Company(35, "物流公司"),
    SendCycle(36, "发货周期"),
    Title(37, "Title"),
    Description(38, "Description"),
    Keywords(39, "Keywords");

    private Integer code;
    private String name;

    CommodityTemplateEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getNameByCode(Integer code) {
        CommodityTemplateEnum typeEnum = Arrays.stream(CommodityTemplateEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return typeEnum == null ? "" : typeEnum.getName();
    }

    public static Boolean contains(Integer code) {
        return Arrays.stream(CommodityTemplateEnum.values()).anyMatch(e -> e.getCode().equals(code));
    }
}
